-- keep the "handles" to the menus in these globals
global menu1
put NewMenu("XrefText/M","Go To Reference","Create Reference", "(-","Back Up","Back To Index","(-","New XrefText Stack", "Toggle Picture","Import Text","Output","(-","XrefText-M Help")into menu1
if menu1 is 0 then answer("Unable to make menu 'BEEP'") with "Drat"
end openstack
on closestack
global prioruserlevel
set the userLevel to prioruserlevel
set the loc of msg to 22,300
-- delete the menus we've created using
--the globals saved in openStack
global menu1
put DeleteMenu(menu1) into menu1
-- clearing global for safety
end closestack
on doMenu which
-- get our menu items from doMenu before HyperCard does...
global menu1, menu2
-- for CheckMenu and EnableMenu below
if which is "Go To Reference" then
put the selection into holder
push card
visual effect wipe right to black
visual effect wipe left
find holder in field keywords
if the result is not empty then
answer "No match for keyword " "e& holder"e
pop card
end if
else if which is "Create Reference" then
put the selection into holder
type ">" & holder & "<"
push card
find holder in field keywords
if the result is not empty then
doMenu New Card
put holder into field keywords
set the name of this card to holder
get the number of lines in card field finder of card theIndex
put holder into line it+1 of card field finder of card theIndex
else
put the length of holder into hl
put the length of word 1 of field keywords into kl
if hl<>kl then
answer "Close match but not exact!" with "Good Enough" or "New Card"
if it contains "New" then
set lockscreen to true
go prev
doMenu New Card
put holder into field keywords
set the name of this card to holder
get the number of lines in card field finder of card theIndex
put holder into line it+1 of card field finder of card theIndex
set lockscreen to false
end if
end if
end if
else if which is "Back Up" then
if the number of this card = 1 then
answer "Careful. You might leave this stack." with Cancel or OK
if it = "OK" then
visual effect wipe left to black
visual effect wipe right
go back
else
exit doMenu
end if
else
visual effect wipe left to black
visual effect wipe right
pop card
end if
else if which is "Back To Index" then
if the number of this card > 1 then
-- visual effect wipe down to black
visual effect iris close to white
visual effect dissolve
go to first card
else
play boing
answer "You're already at the first card!"
end if
else if which is "XrefText-M Help" then
visual effect dissolve
go card ayuda
else if which is "Toggle Picture" then
if the number of this card > 2 then
answer "Change to Picture or Text?" with Text or Picture
if it contains "Text" then
show tool window
choose select tool
doMenu Select All
doMenu Clear Picture
choose browse tool
hide tool window
hide pattern window
else
show pattern window
show tool window
choose rectangle tool
set filled to false
drag from (item 1 of the rect of field keywords), (item 2 of the rect of field keywords) to (item 3 of the rect of field keywords), (item 4 of the rect of field keywords)
drag from 0,28 to 512,342
choose bucket tool
set pattern to 1
click at 250,250
choose text tool
set the textfont to Geneva
set the textsize to 9
click at 10,320
type "Don't use eraser. Use white brush instead."
click at 10,330
type "Choosing Browse Tool will show XrefText/M menu."
choose brush tool
end if
else
play boing
answer "Uh-uh. You don't want to change this card."
end if
else if which is "Import Text" then
if the number of this card > 2 then
if field body is empty then
put FileName("TEXT") into theFile
if theFile is not empty then
open file theFile
read from file theFile for 16000
put it into bkgnd field body
close file theFile
end if
else
answer "Import Text: Replace or Add to field contents?" with "Replace" or "Add" or "Cancel"
if it = "Cancel" then exit mouseup
if it = "Replace" then
put FileName("TEXT") into theFile
if theFile is not empty then
open file theFile
read from file theFile for 16000
put it into bkgnd field body
close file theFile
end if
else
put return after last line of bkgnd field body
put FileName("TEXT") into theFile
if theFile is not empty then
open file theFile
read from file theFile for 16000
put the number of lines in field body into liner
put it after line liner of bkgnd field body
close file theFile
end if
end if
end if
else
play boing
Answer "Don't import to Index or Help Card!"
end if
else if which is "Output" then
answer "Output to printer or to text file?" with "Printer" or "File" or "Cancel"
if it = "Cancel" then
exit doMenu
else if it = "Printer" then
answer "Print the stack or a report of its text" with "Stack" or "Report" or "Cancel"
if it = "Cancel" then
exit doMenu
else if it = "Stack" then
doMenu Print Stack...
else if it = "Report" then
doMenu Print Report...
end if
else if it = "File" then
answer "Save a file of the Stack or of this Card?" with "Stack" or "Card" or "Cancel"
if it = "Cancel" then
exit mouseup
else if it = "Stack" then
put the number of cards into counter
go to first card
put the short name of this stack & ".text" into tfilename
Get PutFile("Save text as:",tfilename)
if it is empty then exit doMenu
put it into textfile
set cursor to 4
set the loc of message to 10,120
put "Writing to file " & textfile & ". Please wait..."into message
open file textfile
repeat (counter - 1)
go next card
write field keywords to file textfile
write return to file textfile
write field body to file textfile
write return to file textfile
write return to file textfile
end repeat
close file textfile
go first card
play harpsichord c e g bb
flash 1
put "Done." into message
wait 2 seconds
hide message
else if it = "Card" then
put the short name of this card & ".text" into tfilename
Get PutFile("Save text as:",tfilename)
if it is empty then exit doMenu
put it into textfile
open file textfile
write field keywords to file textfile
write return to file textfile
write field body to file textfile
close file textfile
end if
end if
else if which is "New XrefText Stack" then
put the short name of this stack into checker
doMenu New Stack...
get the short name of this stack
if it = checker then exit doMenu
put it into field "keywords"
push card
go back
---
go to second card
doMenu "Copy Card"
pop card
doMenu "Paste Card"
push card
---
go to first card of stack checker
doMenu "Copy Card"
pop card
go prev
doMenu "Paste Card"
click at the loc of button "Re-Index"
else pass doMenu
-- Remember to pass on menu commands you don't trap!
end doMenu
on idle
-- call ShowMenu every so often just in case our menus vanished
global menu1, lastTick
if (the ticks-lastTick)>120 then
-- gives better performance than on every iteration